#ifndef SRVIDEOTHREAD_H
#define SRVIDEOTHREAD_H

#include <QThread>
#include <mutex>
#include <list>

#include "isrvideoshow.h"
#include "SrDecode.h"

class SrVideoWidget;


class SrVideoThread:public QThread
{
public:
    SrVideoThread();

    ~SrVideoThread();

    // 打开,不管成功与否都清理
    virtual bool Open(AVCodecParameters *codecpar, ISrVideoShow *show, int width, int height);
    // 清理资源, 停止线程
    virtual void Close();


    virtual void Push(AVPacket *pkt);

    // 清理队列
   virtual void Clear();

    void run();
public:
    int _maxList = 100; // 最大队列
    bool _isExit = false;

    // 同步时间, 由外部传入
    long long _syncPts = 0;

private:
    std::list<AVPacket *> _packs;
    std::mutex _mux;
    SrDecode *m_video_decode;
    ISrVideoShow *m_video_show;

    long long videoPts = 0;
};

#endif // SRVIDEOTHREAD_H
